<?php

namespace App\Models\nursery;

use App\Common\statement\CommonStatement;
use App\Models\base\traits\HasMajor;
use App\Models\base\traits\HasOwner;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\nursery\MajorOrder
 *
 * @property int $id
 * @property string $nu 订单编号
 * @property int $user_id 下单用户ID
 * @property int $major_id 专业ID
 * @property int $major_user_id 育婴师id
 * @property string $name 联系人姓名
 * @property string $phone 联系人电话
 * @property string $address 服务地址
 * @property string $service_at 服务时间
 * @property int $status 订单状态 -1 =>已删除   0 => 待付款  1=>待服务(已付款),2=>已完成
 * @property float $star 客户评分
 * @property string $evaluate 评价内容
 * @property string|null $evaluate_tags 评价标签
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \App\Models\nursery\Major $major
 * @property-read \App\Models\User $major_user
 * @property-read \App\Models\User $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder owner($userId)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereAddress($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereEvaluate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereEvaluateTags($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereMajorId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereMajorUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereNu($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereServiceAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereStar($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereUserId($value)
 * @mixin \Eloquent
 * @property float $price 价格
 * @property-read mixed $status_text
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder wherePrice($value)
 * @property int $major_del 育婴师是否删除订单
 * @property int $user_del 用户是否删除订单
 * @property-read mixed $check
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereMajorDel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\nursery\MajorOrder whereUserDel($value)
 */
class MajorOrder extends Model
{
    use HasMajor,HasOwner;


    public function major_user()
    {
        return $this->belongsTo(User::class,'major_user_id');
    }

    protected $fillable = [
        'nu','major_user_id','name','phone','address','service_at','major_id','user_id','price'
    ];

    public function getCheckAttribute()
    {
        $map['user_id'] = $this->major_user_id;
        return Check::where($map)->first();
    }

    public function getStatusTextAttribute()
    {
        return CommonStatement::major_orders[$this->status];
    }


}
